﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using Pavilion.NodeDesigner;
using System.Windows;
using System.Windows.Shapes;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Documents;

namespace Pavilion.NodeDesigner.Commands
{

    #region CreateLineAdorner

    public class CreateLineAdorner : ICommand
    {
        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object startingPoint)
        {
            var anchor = startingPoint as Anchor;
            if (anchor == null)
                return;

            var canvas = NewWayHelper.GetAncestor(anchor, typeof(Canvas)) as Canvas;
            var contentControl = NewWayHelper.GetAncestor(anchor, typeof(ContentControl)) as ContentControl;

            var adornerLayer = AdornerLayer.GetAdornerLayer(canvas);
            if (adornerLayer == null)
                return;

            var lineAdorner = new LineAdorner(canvas, anchor);
            adornerLayer.Add(lineAdorner);
        }
    } 

    #endregion

    #region ChangeConnectionAnchor

    public class ChangeConnectionAnchor : ICommand
    {
        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            Anchor anchor = null;
        }
    }

    #endregion
}
